/* 清除浮动 */
@mixin clearfix {
  &:after {
    clear: both;
    content: '.';
    display: block;
    height: 0;
    line-height: 0;
    overflow: hidden;
  }
  *height: 1%;
}

/* 画三角形 */
@mixin triangle($width:10px,$direction:top,$color:$bgBlueLight) {
  border: $width solid transparent;
  @if ($direction == top) { // 上三角
    border-bottom-color: $color;
  }
  @if ($direction == bottom) { // 下三角
    border-top-color: $color;
  }
  @if ($direction == left) { // 左三角
    border-right-color: $color;
  }
  @if ($direction == right) { // 右三角
    border-left-color: $color;
  }
}



/* 圆形盒子 */
@mixin circle($size: 11px,$bg: #fff) {
  border-radius: 50%;
  width: $size;
  height: $size;
  line-height: $size;
  text-align: center;
  background: $bg;
}

/* 定位上下左右居中 */
@mixin center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* 背景 */
@mixin bg {
  background-position: center center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

/* 行高和居中 */
@mixin centerlh($height) {
  height:$height;
  line-height:$height;
  text-align: center;
}

/* 单/多行超出省略 */
@mixin ellipsis($clamp: 1) {
  overflow: hidden;
  text-overflow: ellipsis;
  @if($clamp==1) {
    white-space: nowrap;
  }
  @else {
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: $clamp;
    -webkit-box-orient: vertical;
  }
}

/* 设配多倍图 */
@mixin bgSetUp($url){
  background-image: url( $url + ".png");
   @media (-webkit-min-device-pixel-ratio: 2),(min-device-pixel-ratio: 2){
    background-image: url( $url + "@2x.png");
  }
  @media (-webkit-min-device-pixel-ratio: 3),(min-device-pixel-ratio: 3){
    background-image: url( $url + "@3x.png");
  }
}


/*弹性盒子（传入null不设置该属性）*/
@mixin flexBox($direction: row, $justify: null, $align: null, $flex-wrap: null) {
    display: flex;
    @if ($direction!=null) {
        flex-direction: $direction;
    }
    @if ($justify!=null) {
        justify-content: $justify;
    }
    @if ($align!=null) {
        align-items: $align;
    }
    @if ($flex-wrap != null) {
        flex-wrap: $flex-wrap;
    }
}

/* 兼容IE透明度写法 */
@mixin opacity($number: 0.5) {
  opacity: $number;
  filter: alpha(opacity=#{$number * 100});
}

/* 修改placeholder */
@mixin placeholderColor($color: #fff) {
  &::-webkit-input-placeholder {
    color: $color;
  }
  &::-moz-placeholder {
    /* Mozilla Firefox 19+ */
    color: $color;
  }
  &:-moz-placeholder {
    /* Mozilla Firefox 4 to 18 */
    color: $color;
  }
  &:-ms-input-placeholder {
    /* Internet Explorer 10-11 */
    color: $color;
  }
}

/* 移动端1像素底边 */
@mixin borderBottom($color) {
  position: relative;
  &::after {
    /* 其他的也类似 */
    content: '';
    display: block;
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    transform: scale(1, .5);
    transform-origin: 0 bottom;
    background-color: $color;
  }
}

/* 移动端1像素顶边 */
@mixin borderTop($color) {
  position: relative;
  &::before {
    /* 其他的也类似 */
    content: '';
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 1px;
    transform: scale(1, .5);
    transform-origin: 0 top;
    background-color: $color;
    z-index: 2;
  }
}

/* css3动画 默认3s宽度到200px */
@mixin animation($from:(width:0px),$to:(width:200px),$name:mymove,$animate:mymove 2s 1 linear infinite) {
  -webkit-animation: $animate;
  -o-animation: $animate;
  animation: $animate;
  @keyframes #{$name}
  {
    from {
      @each $key, $value in $from {
        #{$key}: #{$value};
      }
    }
    to {
      @each $key, $value in $to {
        #{$key}: #{$value};
      }
    }
  }
  @-webkit-keyframes #{$name}
  {
    from {
      @each $key, $value in $from {
        $key: $value;
      }
    }
    to {
      @each $key, $value in $to {
        $key: $value;
      }
    }
  }
}





/* 链接样式 */
@mixin hoverStyle($style:(color:#d9fdff),$hoverStyle:(color:#306eff)) {
  text-decoration: none;
  @each $key, $value in $style {
    #{$key}: #{$value};
  }
  @if ($hoverStyle!=null & & $hoverStyle!="") {
    &:hover {
      @each $key, $value in $hoverStyle {
        #{$key}: #{$value};
      }
    }
  }
}


/* 定义滚动条样式 圆角和阴影不需要则传入null */
@mixin scrollBar($width:10px,$height:10px,$outColor:$bgColor,$innerColor:$bgGrey,$radius:5px,$shadow:null) {
  /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
  &::-webkit-scrollbar {
    width: $width;
    height: $height;
    background-color: $outColor;
  }

  /*定义滚动条轨道 内阴影+圆角*/
  &::-webkit-scrollbar-track {
    @if ($shadow!=null) {
      -webkit-box-shadow: $shadow;
    }
    @if ($radius!=null) {
      border-radius: $radius;
    }
    background-color: $outColor;
  }

  /*定义滑块 内阴影+圆角*/
  &::-webkit-scrollbar-thumb {
    @if ($shadow!=null) {
      -webkit-box-shadow: $shadow;
    }
    @if ($radius!=null) {
      border-radius: $radius;
    }
    background-color: $innerColor;
    border: 1px solid $innerColor;
  }
}
